home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Multimedia / Movie3.0 / Source / xanim / xanim_rle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-02  |  15.0 KB  |  558 lines

  1.  
  2. /*
  3.  * xanim_rle.c
  4.  *
  5.  * Copyright (C) 1993,1994 by Mark Podlipec. 
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified and redistributed without
  9.  * fee for non-commerical purposes provided that this copyright notice is
  10.  * preserved intact on all copies and modified copies.
  11.  * 
  12.  * There is no warranty or other guarantee of fitness of this software.
  13.  * It is provided solely "as is". The author(s) disclaim(s) all
  14.  * responsibility and liability with respect to this software's usage
  15.  * or its effect upon hardware or computer systems.
  16.  *
  17.  */
  18. #include "xanim_rle.h"
  19.  
  20. LONG Is_RLE_File();
  21. ULONG RLE_Read_File();
  22. ULONG RLE_Read_Header();
  23. ULONG RLE_Get_Image();
  24. void RLE_Read_Row();
  25.  
  26. XA_ACTION *ACT_Get_Action();
  27. XA_CHDR   *ACT_Get_CMAP();
  28. XA_CHDR *CMAP_Create_332();
  29. XA_CHDR *CMAP_Create_Gray();
  30. XA_CHDR *CMAP_Create_CHDR_From_True();
  31. UBYTE *UTIL_RGB_To_Map();
  32. UBYTE *UTIL_RGB_To_FS_Map();
  33. ULONG UTIL_Get_LSB_Short();
  34. void ACT_Setup_Mapped();
  35. void ACT_Add_CHDR_To_Action();
  36.  
  37. ULONG rle_imagex, rle_imagey, rle_imagec;
  38. ULONG rle_max_imagex, rle_max_imagey;
  39. ULONG rle_xpos,rle_ypos;
  40. ULONG rle_image_size;
  41. ColorReg rle_cmap[256];
  42. UBYTE bg_color[3];
  43. UBYTE rle_chan_map[3][256];
  44. XA_CHDR *rle_chdr;
  45. UBYTE *rle_pic;
  46.  
  47. static RLE_FRAME *rle_frame_start,*rle_frame_cur;
  48. static ULONG rle_frame_cnt;
  49. static RLE_HDR rle_hdr;
  50. static LONG priv_vert_skip;
  51. static LONG priv_scan_y;
  52. static LONG priv_is_eof;
  53. static UBYTE *rle_row_buf,*rle_rows[3];
  54.  
  55. /*
  56.  *
  57.  */
  58. LONG Is_RLE_File(filename)
  59. char *filename;
  60. {
  61.   FILE *fin;
  62.   ULONG data;
  63.  
  64.   if ( (fin=fopen(filename,XA_OPEN_MODE)) == 0) return(XA_NOFILE);
  65.   data = UTIL_Get_LSB_Short(fin);  /* read past size */
  66.   fclose(fin);
  67.   if (data == RLE_MAGIC) return(TRUE);
  68.   return(FALSE);
  69. }
  70.  
  71.  
  72. RLE_FRAME *RLE_Add_Frame(time,act)
  73. ULONG time;
  74. XA_ACTION *act;
  75. {
  76.   RLE_FRAME *rframe;
  77.  
  78.   rframe = (RLE_FRAME *) malloc(sizeof(RLE_FRAME));
  79.   if (rframe == 0) TheEnd1("RLE_Add_Frame: malloc err");
  80.  
  81.   rframe->time = time;
  82.   rframe->act = act;
  83.   rframe->next = 0;
  84.  
  85.   if (rle_frame_start == 0) rle_frame_start = rframe;
  86.   else rle_frame_cur->next = rframe;
  87.  
  88.   rle_frame_cur = rframe;
  89.   rle_frame_cnt++;
  90.   return(rframe);
  91. }
  92.  
  93. void
  94. RLE_Free_Frame_List(rframes)
  95. RLE_FRAME *rframes;
  96. {
  97.   RLE_FRAME *rtmp;
  98.   while(rframes != 0)
  99.   {
  100.     rtmp = rframes;
  101.     rframes = rframes->next;
  102.     FREE(rtmp,0x9999);
  103.   }
  104. }
  105.  
  106.  
  107. ULONG RLE_Read_File(fname,anim_hdr)
  108. char *fname;
  109. XA_ANIM_HDR *anim_hdr;
  110. {
  111.   int i;
  112.   RLE_FRAME *rtmp;
  113.  
  114.  
  115.   rle_frame_start = 0;
  116.   rle_frame_cur = 0;
  117.   rle_frame_cnt = 0;
  118.   rle_imagex = rle_imagey = 0;
  119.   rle_max_imagex = rle_max_imagey = 0;
  120.   rle_imagec = 0;
  121.  
  122.   rle_chdr = 0;
  123.  
  124.   if (RLE_Get_Image(fname,anim_hdr)==FALSE) return(FALSE);
  125.  
  126.     anim_hdr->frame_lst = (XA_FRAME *)
  127.         malloc(sizeof(XA_FRAME) * (rle_frame_cnt + 1));
  128.   if (anim_hdr->frame_lst == NULL)
  129.        TheEnd1("RLE_Read_Anim: malloc err");
  130.  
  131.   rtmp = rle_frame_start;
  132.   i = 0;
  133.   while(rtmp != 0)
  134.   {
  135.     if (i >= rle_frame_cnt)
  136.     {
  137.       fprintf(stderr,"RLE_Read_Anim: frame inconsistency %ld %ld\n",
  138.                 i,rle_frame_cnt);
  139.       break;
  140.     }
  141.     anim_hdr->frame_lst[i].time = rtmp->time;
  142.     anim_hdr->frame_lst[i].act = rtmp->act;
  143.     rtmp = rtmp->next;
  144.     i++;
  145.   }
  146.   anim_hdr->frame_lst[i].time = 0;
  147.   anim_hdr->frame_lst[i].act  = 0;
  148.   anim_hdr->loop_frame = 0;
  149.   if (i > 0) anim_hdr->last_frame = i - 1;
  150.   else i = 0;
  151.   anim_hdr->imagex = rle_max_imagex;
  152.   anim_hdr->imagey = rle_max_imagey;
  153.   anim_hdr->imagec = rle_imagec;
  154.   anim_hdr->imaged = 8;
  155.  
  156.   RLE_Free_Frame_List(rle_frame_start);
  157.   return(TRUE);
  158.  
  159. ULONG 
  160. RLE_Read_Header(fp,rle_hdr)
  161. FILE *fp;
  162. RLE_HDR *rle_hdr;
  163. {
  164.   rle_hdr->magic  = UTIL_Get_LSB_Short(fp);
  165.   if (rle_hdr->magic != RLE_MAGIC) return(FALSE);
  166.  
  167.   rle_hdr->xpos  = UTIL_Get_LSB_Short(fp);
  168.   rle_hdr->ypos  = UTIL_Get_LSB_Short(fp);
  169.   rle_hdr->xsize = UTIL_Get_LSB_Short(fp);
  170.   rle_hdr->ysize = UTIL_Get_LSB_Short(fp);
  171.  
  172.   rle_hdr->flags     = (ULONG)getc(fp) & 0xff;
  173.   rle_hdr->chan_num  = (ULONG)getc(fp) & 0xff;
  174.   rle_hdr->pbits     = (ULONG)getc(fp) & 0xff;
  175.   rle_hdr->cmap_num  = (ULONG)getc(fp) & 0xff;
  176.   rle_hdr->cbits     = getc(fp) & 0xff;
  177.   if (rle_hdr->cbits > 8) TheEnd1("RLE_Read_Header: csize > 256\n");
  178.   if (rle_hdr->cbits == 0) rle_hdr->cbits = rle_hdr->pbits; /*PODGUESS*/
  179.   rle_hdr->csize     =  0x01 << rle_hdr->cbits;
  180.  
  181.   DEBUG_LEVEL1
  182.   {
  183.     fprintf(stderr,"RLE_Read_Header: pos %ld %ld size %ld %ld csize %ld\n",
  184.         rle_hdr->xpos,rle_hdr->ypos,rle_hdr->xsize,rle_hdr->ysize,
  185.         rle_hdr->csize);
  186.     fprintf(stderr,"                 flags %lx chans %ld pbits %ld maps %ld\n",
  187.     rle_hdr->flags,rle_hdr->chan_num,rle_hdr->pbits,rle_hdr->cmap_num);
  188.   }
  189.  
  190.   /* read background colors - only save 1st three */
  191.   if ( !(rle_hdr->flags & RLEH_NO_BACKGROUND) )
  192.   {
  193.     register ULONG i,j;
  194.     j = 1 + (rle_hdr->chan_num / 2) * 2;
  195.     for(i=0; i < j; i++)
  196.     { 
  197.       if (i < 3) bg_color[i] = getc(fp) & 0xff;
  198.       else (void)getc(fp);
  199.     }
  200.   }
  201.   else 
  202.   {
  203.     bg_color[0] = bg_color[1] = bg_color[2] = 0; 
  204.     (void)getc(fp);
  205.   }
  206.  
  207.   /* read all of the color maps - only store 1st three */
  208.   if (rle_hdr->cmap_num)
  209.   {
  210.     register ULONG i,j,d;
  211.     for(i=0; i < rle_hdr->cmap_num; i++)
  212.     {
  213.       for(j=0; j < rle_hdr->csize; j++)
  214.       {
  215.         d = UTIL_Get_LSB_Short(fp);
  216.         if (i < 3) rle_chan_map[i][j] = d >> 8;
  217.       }
  218.     }
  219.     if (rle_hdr->cmap_num == 1) /* singlemap? copy to others */
  220.     {
  221.       for(j=0; j < rle_hdr->csize; j++)
  222.         rle_chan_map[1][j] = rle_chan_map[2][j] = rle_chan_map[0][j];
  223.     } 
  224.   }
  225.   else  /* no maps? then create linear maps */
  226.   { register ULONG i;
  227.     for(i=0;i<rle_hdr->csize;i++) 
  228.     rle_chan_map[0][i] = rle_chan_map[1][i] = rle_chan_map[2][i] = i;
  229.   }
  230.   /* GAMMA adjust map */
  231.   if (   (rle_hdr->chan_num == 3) && (cmap_true_map_flag == TRUE)
  232.       && (xa_gamma_flag==TRUE) )  
  233.   { register ULONG i,j;
  234.     for(j=0;j<3;j++)
  235.       for(i=0;i<rle_hdr->csize;i++)
  236.     rle_chan_map[j][i] = xa_gamma_adj[ rle_chan_map[j][i] ] >> 8;
  237.   }
  238.  
  239.   /* skip comments */
  240.   if (rle_hdr->flags & RLEH_COMMENT)  /* see rle_retrow.c for more details */
  241.   {
  242.     register ULONG d,i,len;
  243.     len = UTIL_Get_LSB_Short(fp);
  244.     for(i=0; i<len; i++)
  245.     {
  246.       d = getc(fp) & 0xff;
  247.     /* if (xa_verbose) fprintf(stderr,"%c",d); */
  248.     }
  249.     if (len & 0x01) getc(fp); /* pad */
  250.   }
  251.  
  252.   /*  if not end of file return ok */
  253.   if ( !feof(fp) )
  254.   {
  255.     rle_imagec = rle_hdr->csize;
  256.     rle_imagex = rle_hdr->xsize;
  257.     rle_imagey = rle_hdr->ysize;
  258.     if (rle_imagex > rle_max_imagex) rle_max_imagex = rle_imagex;
  259.     if (rle_imagey > rle_max_imagey) rle_max_imagey = rle_imagey;
  260.     rle_xpos   = rle_hdr->xpos;
  261.     rle_ypos   = rle_max_imagey - (rle_hdr->ypos + rle_hdr->ysize);
  262.     rle_image_size = rle_imagex * rle_imagey;
  263.      /* POD need to check for initial image having non zero pos and need to
  264.       * check for subsequent images fitting in initial images
  265.       * maybe keep initial positions around to shift subsequent.
  266.       */
  267.     priv_scan_y = rle_hdr->ypos;
  268.     priv_vert_skip = 0;
  269.     priv_is_eof = FALSE;
  270.  
  271.     return(TRUE);
  272.   } else return(False);
  273. }
  274.  
  275.  
  276. ULONG RLE_Get_Image(filename,anim_hdr)
  277. char *filename;
  278. XA_ANIM_HDR *anim_hdr;
  279. {
  280.   XA_ACTION *act;
  281.   FILE *fin;
  282.   int x,y;
  283.   int rle_cnt;
  284.   UBYTE *im_ptr;
  285.  
  286.   if ( (fin=fopen(filename,XA_OPEN_MODE)) == 0)
  287.   {
  288.     fprintf(stderr,"can't open RLE File %s for reading\n",filename);
  289.     return(FALSE);
  290.   }
  291.  
  292.   rle_cnt = 0;
  293.   while ( RLE_Read_Header(fin,&rle_hdr) == TRUE )
  294.   {
  295.     rle_cnt++;
  296.  
  297.     if ( (rle_hdr.chan_num != 1) && (rle_hdr.chan_num != 3) )
  298.             TheEnd1("RLE_Get_Image: only 1 and 3 channels supported");
  299.     /* currently must do this here to init xa_r_mask, etc TBD*/
  300.     if (  (rle_hdr.chan_num == 3) && (cmap_true_map_flag != TRUE)
  301.     && (rle_chdr == 0) )
  302.     {
  303.     if (cmap_true_to_332 == TRUE)
  304.         rle_chdr = CMAP_Create_332(rle_cmap,&rle_imagec);
  305.     else    rle_chdr = CMAP_Create_Gray(rle_cmap,&rle_imagec);
  306.     }
  307.  
  308.     if (xa_verbose) fprintf(stderr,"%ld) pos %ld %ld  size %ld %ld chans %ld\n",
  309.       rle_cnt,rle_xpos,rle_ypos,rle_imagex,rle_imagey,rle_hdr.chan_num);
  310.  
  311.     /* Allocate memory for the input image. */
  312.     if (rle_cnt == 1) 
  313.     {
  314.       ULONG i,num_to_alloc;
  315.       UBYTE *p;
  316.       if (x11_display_type & XA_X11_TRUE) num_to_alloc = 3;
  317.       else num_to_alloc = rle_hdr.chan_num;
  318.       p = rle_row_buf = (UBYTE *)malloc( num_to_alloc * rle_imagex );
  319.       if (rle_row_buf == 0) TheEnd1("RLE rowbuf malloc err");
  320.       for(i=0; i<num_to_alloc; i++) { rle_rows[i] = p; p += rle_imagex; };
  321.     }
  322.     if (    (cmap_true_map_flag == TRUE) && (rle_hdr.chan_num == 3)
  323.         && !(x11_display_type & XA_X11_TRUE) )
  324.         rle_pic = (UBYTE *)malloc( 3 * rle_image_size );
  325.     else    rle_pic = (UBYTE *)malloc( XA_PIC_SIZE(rle_image_size) );
  326.     if (rle_pic == 0) TheEnd1("RLE_Get_Image: malloc err\n");
  327.  
  328.     im_ptr = rle_pic;
  329.     y = rle_imagey; while(y--)
  330.     {
  331.       RLE_Read_Row(fin,&rle_hdr);
  332.  
  333.       /* if three channel image then remap data with rle_chan_map */
  334.       if (rle_hdr.chan_num == 3)
  335.       {
  336.     register int i; register UBYTE *p0,*p1,*p2;
  337.     i = rle_imagex; p0 = rle_rows[0]; p1 = rle_rows[1]; p2 = rle_rows[2];
  338.     while(i--) 
  339.     { 
  340.       *p0++ = rle_chan_map[RLE_RED][(ULONG)(*p0)];
  341.       *p1++ = rle_chan_map[RLE_GREEN][(ULONG)(*p1)]; 
  342.       *p2++ = rle_chan_map[RLE_BLUE][(ULONG)(*p2)]; 
  343.     }
  344.       }
  345.  
  346.       if (x11_display_type & XA_X11_TRUE)
  347.       {
  348.     register int i; register UBYTE *p0,*p1,*p2;
  349.  
  350.     /* expand to rgb if color mapped image */
  351.     if (rle_hdr.chan_num == 1)
  352.     {
  353.       i = rle_imagex; p0 = rle_rows[0]; p1 = rle_rows[1]; p2 = rle_rows[2];
  354.       while(i--)
  355.       { register ULONG d = (ULONG)(*p0);
  356.         *p0++ = rle_chan_map[RLE_RED][d];
  357.         *p1++ = rle_chan_map[RLE_GREEN][d];
  358.         *p2++ = rle_chan_map[RLE_BLUE][d];
  359.       }
  360.     }
  361.  
  362.     i = rle_imagex; p0 = rle_rows[0]; p1 = rle_rows[1]; p2 = rle_rows[2];
  363.         if (x11_bytes_pixel == 1)
  364.         {
  365.           UBYTE *iptr = (UBYTE *)(rle_pic + (y * rle_imagex));
  366.       while(i--) *iptr++ = (UBYTE)
  367.         X11_Get_True_Color((ULONG)(*p0++),(ULONG)(*p1++),(ULONG)(*p2++),8);
  368.     }
  369.         else if (x11_bytes_pixel == 2)
  370.         {
  371.           USHORT *iptr = (USHORT *)(rle_pic + (2 * y * rle_imagex));
  372.       while(i--) *iptr++ = (USHORT)
  373.         X11_Get_True_Color((ULONG)(*p0++),(ULONG)(*p1++),(ULONG)(*p2++),8);
  374.     }
  375.         else
  376.         {
  377.           ULONG *iptr = (ULONG *)(rle_pic + (4 * y * rle_imagex));
  378.       while(i--) *iptr++ = (ULONG)
  379.         X11_Get_True_Color((ULONG)(*p0++),(ULONG)(*p1++),(ULONG)(*p2++),8);
  380.     }
  381.       }
  382.       else if (rle_hdr.chan_num == 1) /* color mapped image */
  383.       {
  384.         im_ptr = (UBYTE *)(rle_pic + y * rle_imagex);
  385.         for(x=0; x < rle_imagex; x++) *im_ptr++ = (UBYTE)rle_rows[0][x];
  386.       }
  387.       else if (cmap_true_map_flag == TRUE) /* 3 channels */
  388.       {
  389.         im_ptr = (UBYTE *)(rle_pic + (3 * y * rle_imagex));
  390.         for(x=0; x < rle_imagex; x++)
  391.     {
  392.       *im_ptr++ = (UBYTE)rle_rows[0][x];
  393.       *im_ptr++ = (UBYTE)rle_rows[1][x];
  394.       *im_ptr++ = (UBYTE)rle_rows[2][x];
  395.     }
  396.       }
  397.       else
  398.       {
  399.         im_ptr =  (UBYTE *)( rle_pic + (y * rle_imagex));
  400.         if (cmap_true_to_332 == TRUE)
  401.     {
  402.           for(x=0; x < rle_imagex; x++)
  403.       {
  404.         *im_ptr++ = CMAP_GET_332( (ULONG)(rle_rows[0][x]),
  405.         (ULONG)(rle_rows[1][x]), (ULONG)(rle_rows[2][x]), CMAP_SCALE8 );
  406.       }
  407.     }
  408.         else 
  409.     {
  410.           for(x=0; x < rle_imagex; x++)
  411.       {
  412.         *im_ptr++ = CMAP_GET_GRAY( (ULONG)(rle_rows[0][x]),
  413.         (ULONG)(rle_rows[1][x]), (ULONG)(rle_rows[2][x]), CMAP_SCALE13 );
  414.       }
  415.     }
  416.       }
  417.     }
  418.  
  419.     act = ACT_Get_Action(anim_hdr);
  420.  
  421.     /* Create Color Maps */
  422.     if (rle_hdr.chan_num == 1) /* images with color maps */
  423.     { register ULONG i;
  424.       for(i=0; i<rle_imagec; i++)
  425.       {
  426.     rle_cmap[i].red   = rle_chan_map[RLE_RED][i];
  427.     rle_cmap[i].green = rle_chan_map[RLE_GREEN][i];
  428.     rle_cmap[i].blue  = rle_chan_map[RLE_BLUE][i];
  429.       }
  430.       rle_chdr = ACT_Get_CMAP(rle_cmap,rle_imagec,0,rle_imagec,0,8,8,8);
  431.     }
  432.     else if (cmap_true_map_flag == TRUE)  /* 3 channels */
  433.     {
  434.       UBYTE *tpic;
  435.  
  436.       if (    (cmap_true_to_all == TRUE)
  437.           || ((cmap_true_to_1st == TRUE) && (rle_chdr == 0) )
  438.          )        rle_chdr = CMAP_Create_CHDR_From_True(rle_pic,8,8,8,
  439.                 rle_imagex,rle_imagey,rle_cmap,&rle_imagec);
  440.       else if ( (cmap_true_to_332 == TRUE) && (rle_chdr == 0) )
  441.             rle_chdr = CMAP_Create_332(rle_cmap,&rle_imagec);
  442.       else if ( (cmap_true_to_gray == TRUE) && (rle_chdr == 0) )
  443.             rle_chdr = CMAP_Create_Gray(rle_cmap,&rle_imagec);
  444.  
  445.       if (cmap_dither_type == CMAP_DITHER_FLOYD)
  446.         tpic = UTIL_RGB_To_FS_Map(0,rle_pic,rle_chdr,
  447.                 rle_imagex,rle_imagey,TRUE);
  448.       else
  449.         tpic = UTIL_RGB_To_Map(0,rle_pic,rle_chdr,rle_imagex,rle_imagey,TRUE);
  450.       FREE(rle_pic,0x9999);
  451.       rle_pic = tpic;
  452.     } /* NOTE: 332 and Gray Cases are done much earlier */
  453.     else  /* 3 channels to either gray or 332 */
  454.     {
  455.       if (rle_chdr == 0)  /* error, this should have happened earlier */
  456.     TheEnd1("RLE_Read_File: 332/gray error");
  457.     }
  458.  
  459.     if (x11_display_type & XA_X11_TRUE)
  460.     { 
  461.       ACT_Setup_Mapped(act,rle_pic, 0,
  462.                      rle_xpos,rle_ypos,rle_imagex,rle_imagey,
  463.                      rle_imagex,rle_imagey,FALSE,0,TRUE,TRUE,TRUE);
  464.     }
  465.     else
  466.     { 
  467.       ACT_Setup_Mapped(act,rle_pic, rle_chdr,
  468.                      rle_xpos,rle_ypos,rle_imagex,rle_imagey,
  469.                      rle_imagex,rle_imagey,FALSE,0,TRUE,TRUE,FALSE);
  470.       ACT_Add_CHDR_To_Action(act,rle_chdr);
  471.     }
  472.     RLE_Add_Frame(17,act);
  473.  
  474.   }
  475.   if (rle_row_buf) { FREE(rle_row_buf,0x999); rle_row_buf=0; }
  476.   fclose(fin);
  477.   return(TRUE);
  478. }
  479.  
  480.  
  481. void RLE_Read_Row(fp,rle_hdr)
  482. FILE *fp;
  483. RLE_HDR *rle_hdr;
  484. {
  485.   ULONG posx,opcode,opdata,data;
  486.   ULONG ymax,channel,exit_flag;
  487.  
  488.   ymax = rle_ypos + rle_imagey;
  489.   posx = 0;
  490.   exit_flag = 0;
  491.  
  492.   /* clear to background if necessary */
  493.   if ( !(rle_hdr->flags & RLEH_NO_BACKGROUND) ) 
  494.   { register ULONG i;
  495.     for(i=0; i < rle_hdr->chan_num; i++)
  496.         memset( (char *)rle_rows[i], bg_color[i], rle_hdr->xsize);
  497.   }
  498.  
  499.   if (priv_vert_skip) 
  500.   {
  501.     priv_vert_skip--; 
  502.     DEBUG_LEVEL3 fprintf(stderr,"  Prev Skip %ld\n",priv_vert_skip);
  503.     return;
  504.   }
  505.   if ( priv_is_eof ) return;  /* EOF already encountered */
  506.  
  507.   while(!exit_flag)
  508.   {
  509.     opcode = getc(fp) & 0xff;
  510.     opdata = getc(fp) & 0xff;
  511.     switch( RLE_OPCODE(opcode) )
  512.     {
  513.       case RLE_SkipLinesOp:
  514.     if (RLE_LONGP(opcode))  priv_vert_skip = UTIL_Get_LSB_Short(fp); 
  515.         else priv_vert_skip = opdata;
  516.     priv_vert_skip--;  /* count this line */
  517.     posx = 0;
  518.         exit_flag = 1; 
  519.     break;
  520.       case RLE_SetColorOp:
  521.     channel = opdata; posx = 0;
  522.     break;
  523.       case RLE_SkipPixelsOp:
  524.     if (RLE_LONGP(opcode))  posx += UTIL_Get_LSB_Short(fp); 
  525.         else posx += opdata;
  526.     break;
  527.       case RLE_ByteDataOp:
  528.     { register ULONG i;
  529.     if (RLE_LONGP(opcode))  opdata = UTIL_Get_LSB_Short(fp); 
  530.     opdata++; i = opdata;
  531.         if (channel < 3)
  532.           while(i--) {rle_rows[channel][posx] = getc(fp); posx++;}
  533.     else    { posx += opdata; while(i--) (void)getc(fp); }
  534.     if (opdata & 0x01) (void)getc(fp);  /* pad to SHORT */
  535.     }
  536.     break;
  537.       case RLE_RunDataOp:
  538.     if (RLE_LONGP(opcode))  opdata = UTIL_Get_LSB_Short(fp); 
  539.     opdata++;
  540.     data = getc(fp) & 0xff;  (void)getc(fp);
  541.         if (channel < 3)
  542.         while(opdata--) {rle_rows[channel][posx] = data; posx++;}
  543.     else    posx += opdata;
  544.     break;
  545.       case RLE_EOFOp:
  546.     priv_is_eof = TRUE;
  547.     exit_flag = 1;
  548.     break;
  549.       default:
  550.     fprintf(stderr,"RLE unknown opcode %lx\n",RLE_OPCODE(opcode));
  551.     exit_flag = 1;
  552.     } /* end of opcode switch */
  553.   } /* end of while */
  554. }
  555.        
  556.  
  557.